package exception;

/**
 * 使用当前类测试异常的抛出
 */
public class Person {
    private int age;//年龄

    public int getAge() {
        return age;
    }

    public void setAge(int age) throws IllegalAgeException {
        if (age<0||age>120){
            //throw new RuntimeException("年龄不符合要求！");
            throw new IllegalAgeException("年龄不符");
        }
        this.age = age;
    }
}



